<?php

namespace app\admin\model;

use app\common\model\Base;

/**
 * Class Classes
 * @package app\admin\model
 * class班级类，加es避免关键字冲突
 */
class Classes extends Base {
  protected $name = 'class';


  public function initialize() {
    parent::initialize();
  }

  public function getTeacherClass($uid, $field = TRUE, $key = NULL) {

    $map = ['teacher_uid' => $uid];
    if ($key === NULL) {
      return self::where($map)->field($field)->find();
    } else {
      return self::where($map)->column($field, $key);
    }
  }

  public function getTeacherClassId($uid) {
    $row = self::getTeacherClass($uid);

    return $row ? $row['id'] : 0;
  }


}